import {createRouter, createWebHashHistory} from 'vue-router'
import Home from "@/components/Home.vue";
import PageNotFound from "@/components/PageNotFound.vue";
import Display from "@/components/Display.vue";
import AppDetector from "@/components/Display/app-detector.vue";
import AppChatbox from "@/components/Display/app-chatbox.vue";

const routes = [
    {
        path: '/',
        redirect: '/display'
    },
    {
        path: '/index',
        redirect: '/display',
        component: Home,
        meta: {
            title: "主页"
        }
    },
    {
        path: '/display',
        component: Display,
        redirect: '/display/detector',
        meta: {
            title: "展示"
        },
        children: [
            {
                path: '/display/detector',
                component: AppDetector,
            },
            {
                path: '/display/chatbox',
                component: AppChatbox,
            },
        ]
    },
    {
        path: '/404',
        component: PageNotFound,
        meta: {
            title: "404"
        }
    },
    {
        path: '/:catchAll(.*)',
        redirect: "/404"
    }
]

const routerHash = createRouter({
    history: createWebHashHistory(),
    routes
})
routerHash.afterEach(() => {
    scrollTo(0, 0)
})
export default routerHash